<script type="text/javascript">
    $(function() {
        var oTable1 = $('#registros').dataTable({
            "aoColumns": [
                {"bSortable": false},
                null, null, null, null,
                {"bSortable": false}
            ]});

        $('table th input:checkbox').on('click', function() {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                    .each(function() {
                this.checked = that.checked;
                $(this).closest('tr').toggleClass('selected');
            });

        });

        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2))
                return 'right';
            return 'left';
        }
    });

    function ventRegistroInf(reg) {
        ventana("infoRegistro", 520, 540, true, "center");
        registroInfo('<?php echo base_url('intranet/registro/infoRegistro') ?>/' + reg);
        $('#infoRegistro').dialog('open');
    }
</script>
<div class="page-content">
    <div class="page-header position-relative">
        <h1>Registros<small><i class="icon-double-angle-right"></i> Listado</small></h1>
    </div>

    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-header"><h4>Listado de Registros por fecha(as) </h4>
                    <span class="widget-toolbar">
                        <a data-action="collapse" href="#">
                            <i class="icon-chevron-up"></i>
                        </a>
                    </span>
                </div>
                <div class="widget-body">
                    <div class="widget-body-inner">
                        <div class="widget-main">
                            <div class="row-fluid">
                                <form class="form-search" action="<?php echo base_url("intranet/administrador/registros"); ?>" method="POST" >
                                    <span>Desde: <input type="text" name="fecha1" class="input-medium search-query fechaMY" readonly="true" /></span>
                                    <span style="margin-left: 25px">Hasta: <input type="text" name="fecha2" class="input-medium search-query fechaMY" readonly="true" /></span>
                                    <span style="margin-left: 25px">
                                        <button type="submit" class="btn btn-danger btn-small">
                                            Buscar
                                            <i class="icon-search icon-on-right bigger-110"></i>
                                        </button></span>
                                </form>
                            </div>
                            <div class="dataTables_wrapper" role="grid">
                                <div>
                                    <table id="registros" class="table table-striped table-bordered table-condensed table-hover"> 
                                        <thead>
                                            <tr><th>Cliente</th>
                                                <th>DNI</th>
                                                <th>Habitación</th>
                                                <th>Fecha Ingreso</th>
                                                <th>Personal</th>
                                                <th>Detalle</th>
                                            </tr>
                                        </thead>
                                        <tbody id="datosRegistro">
                                            <?php
                                            if (isset($registros)) :
                                                foreach ($registros as $fila):
                                                    ?>
                                                    <tr>
                                                        <td><?php echo $fila->nombre; ?></td>
                                                        <td><?php echo $fila->dni; ?></td>
                                                        <td><?php echo $fila->nro_habi; ?></td>
                                                        <td><?php echo $fila->fec_ing; ?></td>
                                                        <td><?php echo $fila->nom_per; ?></td>
                                                        <td class="td-actions">
                                                            <div class="hidden-phone visible-desktop action-buttons">
                                                                <a class="green" href="#"><i class=" icon-exclamation-sign bigger-150" title="Información adicional" onclick="ventRegistroInf(<?php echo $fila->idRegistro ?>)"></i></a>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <?php
                                                endforeach;
                                            endif;
                                            ?>   
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="infoRegistro"></div>